package com.abel.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.abel.util.UserSessionLocator;

public class LogoutController implements Controller{

	@Override
	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		//reset authprincipal
		UserSessionLocator.getUserSession().setAuthPrincipal(null);
		//reset person
		UserSessionLocator.getUserSession().setPerson(null);
		//reset UserSession
		UserSessionLocator.invalidateUserSession();
		
		return new ModelAndView("redirect:login.xhtm?logout=true");
	}

}
